package megrez.job.custom.domain;

import java.util.Set;

import org.springframework.data.jpa.domain.Specification;

import lombok.experimental.UtilityClass;

/**
 * 日志查询条件
 * 
 * @author Lucky Yang
 * @since 2.6.9
 */
@UtilityClass
public class LogSpecifications {
    public Specification<Log> empty() {
        return (root, query, builder) -> null;
    }

    public Specification<Log> configIdEqual(String configId) {
        return (root, query, builder) -> builder.equal(root.get("config").get("id"), configId);
    }

    public Specification<Log> stateIn(Set<TaskState> states) {
        return (root, query, builder) -> builder.in(root.get("state")).value(states);
    }
}
